package com.heima.wemedia.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@Slf4j
public class WmChannelServiceImpl extends ServiceImpl<WmChannelMapper, WmChannel> implements WmChannelService {

    @Autowired
    private WmChannelMapper wmChannelMapper;

    @Override
    public ResponseResult channelList() {
        // 1. 构造分页（这一步主要是为了安全考虑，限制这个接口查询数据的最大值）
        Page<WmChannel> page = new Page<>(1, 100);

        // 2. 列表查询
        Page<WmChannel> wmChannelPage = wmChannelMapper.selectPage(page, null);

        // 3. 返回数据
        return ResponseResult.okResult(wmChannelPage.getRecords());
    }
}